#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define int long long 
vector<int> a, b;
int midsearch(int x, int flag) {
    int l = 0, r = a.size() - 1;
    int ret1 = 0, ret2 = 0;
    while(l <= r) {
        int mid = l + (r - l) / 2;
        if(a[mid] > x) {
            r = mid - 1;
            ret1 = mid;
        }else if(a[mid] == x) {
            return x;
        }else {
            l = mid + 1;
            ret2 = mid;
        }
    }
    if(!flag) {
        return a[ret1];
    }else {
        return a[ret2];
    }
}
signed main() {
    int m, n;
    int ret = 0;
    cin >> m >> n;
    for(int i = 0; i < m; i++) {
        int temp;
        cin >> temp;
        a.push_back(temp);
    }
    sort(a.begin(), a.end());
    for(int i = 0; i < n; i++) {
        int temp;
        cin >> temp;
        int x = midsearch(temp, 0);
        int y = midsearch(temp, 1);
        ret += min(abs(x - temp), abs(y - temp));
    }
    cout << ret << endl;
    return 0;
}